from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
from framework.base_page import BasePage
from page.advance_search_page import AdvanceSearchPage

'''首页'''

class HomePage(BasePage):
    def __init__(self, driver: WebDriver = None) -> object:
        super().__init__(driver)
        self.driver.get("https://ceshiren.com")

    def to_advance_search(self) -> AdvanceSearchPage:
        self.click(By.ID, 'search-button', check_loc=(By.CSS_SELECTOR, "a[title='打开高级搜索]"))
        self.click(By.CSS_SELECTOR, "a[title='打开高级搜索]")
        return AdvanceSearchPage(self.driver)

    def home(self):
        self.click(By.ID, 'site-logo')
        self._wait_loading()
        return self

    def _wait_loading(self):
        self.wait_disappear(By.CSS_SELECTOR, '.spinner')